/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/12/12 10:40
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.uaa.repository;

import com.spring.arch.uaa.model.Organization;
import com.spring.arch.uaa.model.OrganizationEmployee;
import com.spring.arch.uaa.model.OrganizationEmployeeRole;
import com.spring.arch.uaa.model.Organization;
import com.spring.arch.uaa.model.OrganizationEmployee;
import com.spring.arch.uaa.model.OrganizationEmployeeRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
 * 组织人员角色持久层接口
 *
 * @author Frank
 * @version 1.0.0.1
 * @since 2019/12/12 10:40
 */
@org.springframework.stereotype.Repository
public interface OrganizationEmployeeRoleRepository extends Repository<OrganizationEmployeeRole, UUID> {

    OrganizationEmployeeRole save(OrganizationEmployeeRole model);

    Optional<OrganizationEmployeeRole> findById(UUID id);

    Page<OrganizationEmployeeRole> findAll(Pageable pageable);

    List<OrganizationEmployeeRole> saveAll(Iterable<OrganizationEmployeeRole> list);

    void delete(OrganizationEmployeeRole tenant);

    void deleteById(UUID id);

    void deleteAllByOrganizationEmployee(OrganizationEmployee employee);

    void deleteAllByOrganizationEmployeeId(UUID organizationEmployeeId);

    void deleteAllByOrganizationEmployeeEmployeeId(UUID employeeId);

    List<OrganizationEmployeeRole> findByOrganizationEmployee(OrganizationEmployee organizationEmployee);

    List<OrganizationEmployeeRole> findByOrganizationEmployeeIn(Iterable<OrganizationEmployee> organizationEmployees);

    List<OrganizationEmployeeRole> findByOrganizationEmployeeId(UUID organizationEmployeeId);

    OrganizationEmployeeRole findByOrganizationEmployeeIdAndRoleCodeAndOrganizationId(UUID orgEmlId, String roleCode,
                                                                                      UUID orgId);

    List<OrganizationEmployeeRole> findByOrganizationEmployeeInAndRoleCode(List<OrganizationEmployee> organizationEmployee, String roleCode);

    List<OrganizationEmployeeRole> findByOrganizationInAndOrganizationDisableFalseAndRoleCodeIsNotIn(
            List<Organization> organizationList,
            List<String> roleCodes);

    List<OrganizationEmployeeRole> findByOrganizationInAndOrganizationDisableFalseAndRoleCodeIn(
            List<Organization> organizationList,
            List<String> roleCodes);

    List<OrganizationEmployeeRole> findByOrganizationProjectIdAndOrganizationDisableFalseAndRoleCodeIn(UUID projectId,
                                                                                                       List<String> roleCodes);

}
